package com.bruip.ch01;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;

/**
 * @author yuxi
 * @version 1.0
 * @date 2025/10/22
 * @Description:
 */
public class Test05_predicate {
    public static void main(String[] args) {
        int[] arr={10,20,30,40,50,60,70,80};
        //判断/过滤-->predicate boolean test(T t)
        Predicate<Integer> p1=new Predicate<Integer>() {
            @Override
            public boolean test(Integer integer) {
                return integer>50;
            }
        };
        //使用lambda表达式
        Predicate<Integer> p2=integer->integer>50;
        List<Integer> result=new ArrayList<>();
        for(int i:arr){
            if(p1.test(i)){
                result.add(i);
            }
        }
        System.out.println(result);
        /*Integer[] res=new Integer[result.size()];
        arr=result.toArray(res);*/
    }
}
